package com.qf.controller;

import com.qf.domain.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.Arrays;

@Controller
@RequestMapping("/test")
@Slf4j
public class TestController {
    @RequestMapping("/echo")
    public String echo(){
        return "index";
    }
    @RequestMapping(value = "/param01",method = RequestMethod.GET)
    public String param01(int id,String name){
        log.info("param01:id={},name={}",id,name);
        return "index";
    }
    @RequestMapping(value = "/param02",method = RequestMethod.POST)
    public String param02(User user){
        log.info("param02:user={}",user);
        return "index";
    }
    @RequestMapping("/param03")
    public String param03(String[] args) {
        log.info("args: {}", Arrays.toString(args));
        return "index";
    }

    @RequestMapping("/param04")
    public String param04(@RequestParam("args") ArrayList<String> args) {
        log.info("args: {}", args);
        return "index";
    }
    @RequestMapping("/redirect")
    public String redirect() {
        return "redirect:/jsp/index.jsp";
    }
    @RequestMapping("/forward")
    public String forward() {
        return "forward:/jsp/index.jsp";
    }
}
